<?php
require_once 'glob.php';
$action=$_REQUEST['action'];
$page=$_REQUEST['page'];
switch ($action) {

	/******************************************************************/
	case 'list':
		$pludir=$_REQUEST['type'];
		$plugins=get_plugins_info('plugins/'.$pludir);  //该文件夹下为支付类型的插件，所以后面的参数可以不写
		$pagesize=10;
		get_list_arr($plugins,'pluginslist','plugins_list.htm',$pagesize,'fypage',$page,'?action=paymentshow&');
		break;
		/******************************************************************************************/

	case 'install':
		if($_REQUEST['name']!==''&&$_REQUEST['name']!==null){
			$post=array(
			name=>$_REQUEST['name'],
			type=>$_REQUEST['type'],
			is_install=>'Y'
			);
			$sql='select is_install from sn_plugins where name="'.$_REQUEST['name'].'"';
			$res=$db->getrow($sql);
			if($res){
				$res=$db->update('sn_plugins',$post,name);
			}else {
				$res=$db->insert('sn_plugins',$post);
			}
			if($res==true){
				echo '<script type="text/javascript">window.history.go(-1);</script>';
			}
		}
		break;
	case 'uninstall':
		if($_REQUEST['name']!==''&&$_REQUEST['name']!==null){
			$post=array(
			name=>$_REQUEST['name'],
			is_install=>'N'
			);
			$res=$db->update('sn_plugins',$post,name);
			if($res==true){
				echo '<script type="text/javascript">window.history.go(-1);</script>';
			}
		}
		break;

	case 'admin':
		require_once 'inc/lib/base/cls_plugins.php';
		$PluginManager=new PluginManager('plugins/'.$_REQUEST['type']);
		if($_POST){
			$admindo=$PluginManager->trigger($_REQUEST['name'],$_REQUEST['admindo'],$_POST);
		}else{
			$admindo=$PluginManager->trigger($_REQUEST['name'],$_REQUEST['admindo']);
		}

		$xueniao->assign('admindo',$admindo);
		$xueniao->display('plugins_config.htm');
		break;

	default:
		//	$xueniao->display('plugins_list.htm');
		break;

}


?>